package domain

import (
	"time"
)

const (
	ClubFormTableName = "club_form"
)
const (
	ClubFormColumnApplication = "Application"
)

type ClubFormType = int64

const (
	ClubFormTypeFresh ClubFormType = iota
	ClubFormTypeNormal
)

var ClubFormTypeValues = map[ClubFormType]string{
	ClubFormTypeFresh:  "fresh",
	ClubFormTypeNormal: "normal",
}

type ClubForm struct {
	ID           int64              `json:"id"`
	ClubID       *int64             `json:"-"`
	Title        string             `json:"title" gorm:"type:varchar(255);not null"`
	Description  string             `json:"description"`
	Value        *JSON              `json:"value" gorm:"type:json"`
	Type         ClubFormType       `json:"type" gorm:"comment:0->Join,_->Other"`
	AllowRepeat  bool               `json:"allow_repeat" gorm:"not null;default:false;"`
	AllowRewrite bool               `json:"allow_rewrite" gorm:"not null;default:false;"`
	CreatedAt    time.Time          `json:"created_at" `
	UpdatedAt    time.Time          `json:"updated_at" `
	Club         *Club              `json:"club" gorm:"foreignKey:ClubID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Application  []*UserApplication `json:"application" gorm:"foreignKey:FormID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
}

type ClubFormDTO struct {
	ID           int64                 `json:"id"`
	ClubID       *int64                `json:"-"`
	Title        string                `json:"title" gorm:"type:varchar(255);not null"`
	Description  string                `json:"description"`
	Value        *JSON                 `json:"value" gorm:"type:json"`
	Type         int64                 `json:"type" gorm:"comment:0->Join,_->Other"`
	AllowRepeat  bool                  `json:"allow_repeat" gorm:"not null;default:false;"`
	AllowRewrite bool                  `json:"allow_rewrite" gorm:"not null;default:false;"`
	CreatedAt    time.Time             `json:"created_at" `
	UpdatedAt    time.Time             `json:"updated_at" `
	Club         *ClubDTO              `json:"club" gorm:"foreignKey:ClubID;constraint:OnUpdate:CASCADE,OnDelete:SET NULL"`
	Application  []*UserApplicationDTO `json:"application" gorm:"foreignKey:FormID"`
}
